#include "UBeltConfig.h"
#include "CHeader.h"
UBeltConfig::UBeltConfig(QWidget *parent)
	: QWidget(parent)
{
	ui.setupUi(this);
}

UBeltConfig::UBeltConfig(CBeltDataBase* pData)
{
	ui.setupUi(this);
	m_pData = pData;
	initUi();
}

UBeltConfig::~UBeltConfig()
{}



void UBeltConfig::initUi()
{
	setUiStyle(this, "Dialog");
	ui.lineEdit_Name->setText(m_pData->m_sBeltName);
	ui.lineEdit_ID->setText(m_pData->m_sId);
	ui.lineEdit_Port->setText("80");
	ui.lineEdit_Port->setEnabled(false);

	if (m_pData->m_sCameraIp == "")
	{
		ui.lineEdit_Ip->setText("127.0.0.1");
	}
	else
	{
		ui.lineEdit_Ip->setText(m_pData->m_sCameraIp);
	}
	
	connect(ui.Btn_Save, SIGNAL(clicked()), this, SLOT(slot_Save()));
	connect(ui.Btn_Cancel, SIGNAL(clicked()), this, SLOT(slot_cancel()));
} 

void UBeltConfig::setStyleSheetFile()
{

}

void UBeltConfig::slot_Save()
{
	m_pData->m_sBeltName = ui.lineEdit_Name->text().trimmed();
	m_pData->m_sCameraIp = ui.lineEdit_Ip->text().trimmed();
	close();

}
void UBeltConfig::slot_cancel()
{
	close();
}